package cagt.tools.standard.poker.holdem;

import java.util.List;
import java.util.Set;

import cagt.tools.LimitedList;
import cagt.tools.standard.StandardCard;

/**
 * Class representing texas holdem table.
 * 
 * @author Konrad
 * 
 */
public class Table extends LimitedList<StandardCard> implements
		Set<StandardCard> {
	public static final int TABLE_LIMIT = 5;
	public static final int USABILITY_SIZE = 3;

	/**
	 * Standard constructor.
	 */
	public Table() {
		super(TABLE_LIMIT);
	}

	/**
	 * Get the first three cards of the table - community cards. If there are
	 * less then 3 cards on the table null will be returned.
	 * 
	 * @return Community cards.
	 */
	public List<StandardCard> getCommunityCards() {
		if (size() == USABILITY_SIZE) {
			return null;
		}
		return subList(0, 2);
	}

	/**
	 * Return the fourth card put on the table.
	 * 
	 * @return The turn.
	 */
	public StandardCard getTurn() {
		return get(3);
	}

	/**
	 * Return the fifth card put on the table.
	 * 
	 * @return The river.
	 */
	public StandardCard getRiver() {
		return get(4);
	}

	/**
	 * Returns whether this table is valid for further analysis.
	 * 
	 * @return True if size is >= than usability size.
	 */
	public boolean isValid() {
		return size() >= USABILITY_SIZE;
	}
}
